using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using MySql.Data.MySqlClient;
namespace WordEveryDay
{
    class DBHelper
    {
        private static MySqlConnection connection;
        public static DataSet dataSet;
        public static bool connectDB()
        {
            MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
            
            builder.UserID = ConfigurationManager.AppSettings["username"];//用户名
            builder.Password = ConfigurationManager.AppSettings["password"];//密码
            builder.Server = ConfigurationManager.AppSettings["sever"];//服务器
            builder.Database = ConfigurationManager.AppSettings["database"];//数据库名
            builder.SslMode = MySqlSslMode.None;
            
            connection = new MySqlConnection(builder.ConnectionString);
            getData();
            return true;
        }

          public static void getData()
        {
            string sql = "select * from enwords";         
            MySqlDataAdapter adapter = new MySqlDataAdapter(sql,connection);
             dataSet = new DataSet();         
            adapter.Fill(dataSet);
              
        }
    }
}